package com.oocl.euc.core.maintenance.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.oocl.euc.audit.AuditEntity;

import javax.persistence.*;

@Entity
@Table(name = "PCRS_FUNCTION_AUTH")
@SequenceGenerator(name = "SEQUENCE_GENERATOR", sequenceName = "FUNCTION_AUTH_SEQUENCE", allocationSize = 1)
public class FunctionAuth extends AuditEntity {

    @Column(name = "FUNCTION_ID")
    private Long functionId;

    @ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.EAGER)
    @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID")
    @JsonIgnoreProperties(ignoreUnknown = true, value = {"roleAuths"})
    private Role role;

    @ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.EAGER)
    @JoinColumn(name = "REQUEST_STATUS_ID")
    private Status status;

    public Long getFunctionId() {
        return functionId;
    }

    public void setFunctionId(Long functionId) {
        this.functionId = functionId;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }


    public FunctionAuth(Long functionId, Role role, Status status) {
        this.functionId = functionId;
        this.role = role;
        this.status = status;
    }

    public FunctionAuth(Long functionId, Role role) {
        this.functionId = functionId;
        this.role = role;
    }

    public FunctionAuth(Long functionId, Status status) {
        this.functionId = functionId;
        this.status = status;
    }

    public FunctionAuth() {

    }
}
